﻿<?php require_once('../../includes/spip_launcher.php'); ?>
$(document).ready(function() {
      insert_index = 0; //индекс добавленых = 0 
//добавляем строку
	   $('.list_form .add_field_button').click(function(){
				var container = $('.list_form .elements_container'),
					content = '<tr>';
/*id*/					content += "<td> ? </td>";
/*чекбокс*/				content += '<td><input type="checkbox" name="elements_insert['+insert_index+'][is_active]"/></td>';
// /*название*/			content += '<td><input type="text" name="elements_insert['+insert_index+'][titre]" value="" style="width: 153px;" /><input type="hidden" name="elements_insert['+insert_index+']" value="" /></td>';insert_index++;
content += '<td><input type="text" name="elements_insert['+insert_index+'][titre]" value="" style="width: 153px;" /></td>';insert_index++;


/*удалить*/				content += '<td><a href="javascript:;" class="delete_link"><?php echo(_T('ecatalogue:delete')); ?></a></td>';
					content += '</tr>';
				container.append(content);
	   });
//удаляем строку      
       $('.list_form .delete_link').live('click', function(){
            if (confirm('<?php echo(_T('ecatalogue:delete_element')); ?> "' + $(this).parent().prev().find('input').val() + '"?')) {                
                var element_id = $(this).data('element-id');
                if (element_id!=undefined) {$('.list_form').append('<input type="hidden" name="elements_delete['+element_id+']" value="'+element_id+'" />');}
                $(this).parent().parent().remove();    
            }                
       });
       $('.reponse_formulaire').delay(3000).fadeOut();
});